#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include "util.h"

int
is_palindrome(const char *s, int length)
{
    const char *p, *q;

    assert(s != NULL && length > 0);
    p = s;
    q = &s[length - 1];
    for (; p < q; ++p, --q)
        if (*p != *q)
            return 0;
    return 1;
}

char *
strtolower(char *s)
{
    char *ptr;

    assert(s != NULL);
    ptr = s;
    while (*ptr) {
        *ptr = tolower(*ptr);
        ptr++;
    }

    return s;
}

int
maxv(int v[], int n)
{
    int i, max;

    assert(v != NULL && n > 0);
    max = v[0];
    for (i = 1; i < n; ++i)
        if (v[i] > max)
            max = v[i];
    return max;
}
